package com.bqtv.sport.dialog

import android.content.Context
import android.view.LayoutInflater
import android.view.View
import android.widget.FrameLayout
import androidx.recyclerview.widget.LinearLayoutManager
import com.bqtv.sport.R
import com.bqtv.sport.adapter.SelectAddressAdapter
import com.bqtv.sport.adapter.SelectBankAdapter
import com.bqtv.sport.databinding.DialogFriendHomeBinding
import com.bqtv.sport.databinding.DialogSelectAddressBinding
import com.bqtv.sport.databinding.DialogSelectBankBinding
import com.bqtv.sport.databinding.DialogSelectPicBinding
import com.chad.library.adapter4.BaseQuickAdapter
import com.hjq.base.BaseDialog
import com.hjq.base.BottomSheetDialog

class FriendHomeDialog {
    class Builder(context: Context) : BaseDialog.Builder<Builder>(context) {
        lateinit var bankDialog: SelectBankAdapter
        var binding: DialogFriendHomeBinding =
            DialogFriendHomeBinding.inflate(
                LayoutInflater.from(context),
                FrameLayout(context),
                false
            )

        init {
            setContentView(binding.root)
            setData()
        }

        fun setData(): Builder {
            setOnClickListener(binding.tvAddBlack, binding.tvDeleteFriend, binding.tvCancel)
            return this
        }

        override fun onClick(view: View) {
            super.onClick(view)

            when (view) {
                binding.tvCancel -> {
                    dismiss()
                }
                binding.tvAddBlack -> {
                    clickResult?.onAddBlackClick()
                    dismiss()
                }
                binding.tvDeleteFriend -> {
                    clickResult?.onDeleteFriendClick()
                    dismiss()
                }
            }
        }

        fun setIsBlack(isBlack: Boolean): Builder {
            if (isBlack){
                binding.tvDeleteFriend.text = getString(R.string.cancel_black_list)
            }else{
                binding.tvDeleteFriend.text = getString(R.string.add_black_list)
            }
            return this
        };

        override fun createDialog(context: Context, themeId: Int): BaseDialog {
            val dialog = BottomSheetDialog(context, themeId)
            dialog.getBottomSheetBehavior().setSkipCollapsed(true)
            return dialog
        }

        var clickResult: ClickResult? = null

        interface ClickResult {
            fun onAddBlackClick()
            fun onDeleteFriendClick()
        }
    }
}